package com.chianghao.qyt.config;

import com.chianghao.frame.web.mvc.html.IErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class DemoConfig {

    private final static Map<Integer,String> stateMap = new HashMap<>();

    static {
        stateMap.put(404,"error/404");
        stateMap.put(401,"error/401.html");
        stateMap.put(400,"error/400");
        stateMap.put(500,"error/500");
    }


    @Bean
    public IErrorPage errorPage(){
        return state -> {
            if(stateMap.containsKey(state)){
                return stateMap.get(state);
            }
            return "error/500";
        };
    }


}
